var t = getApp();

Page({
    data: {
        list: [],
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        optype: 1
    },
    onLoad: function(t) {
        t.type && (this.data.optype = t.type), this.getData();
    },
    onReady: function() {},
    getData: function() {
        var a = this, e = "";
        1 == this.data.optype ? e = t.getNetAddresss("plugin.merchant.frontend.store.list.storeListByStaff") : 2 == this.data.optype && (e = t.getNetAddresss("plugin.merchant.frontend.store.list.storeList")), 
        t._getNetWork({
            url: e,
            data: {
                page: 1
            },
            success: function(t) {
                var e = t.data;
                1 === e.result ? a.setData({
                    list: e.data.store_list.data,
                    total_page: e.data.store_list.last_page
                }) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    toShop: function(t) {
        var a = t.currentTarget.dataset.storeid;
        wx.navigateTo({
            url: "/packageC/o2o/HomeSeller/HomeSeller?store_id=" + a
        });
    },
    getMoreData: function() {
        var a = this, e = {
            page: this.data.page
        }, o = "";
        this.data.isLoadMore = !1, this.data.page >= this.data.total_page || (this.data.page = this.data.page + 1, 
        e.page = this.data.page, 1 == this.data.optype ? o = t.getNetAddresss("plugin.merchant.frontend.store.list.storeListByStaff") : 2 == this.data.optype && (o = t.getNetAddresss("plugin.merchant.frontend.store.list.storeList")), 
        t._getNetWork({
            url: o,
            data: e,
            success: function(t) {
                var e = t.data;
                if (1 === e.result) {
                    var o = e.data.store_list.data;
                    a.setData({
                        list: a.data.list.concat(o)
                    }), a.data.page < e.data.store_list.last_page && (a.data.isLoadMore = !0);
                } else a.data.page = a.data.page - 1, a.data.isLoadMore = !1;
            },
            fail: function(t) {
                console.log(t);
            }
        }));
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {}
});